﻿@{
    ViewBag.Title = "Index";
}

<h2>Wish list</h2>
<br />

@Html.Partial("Styles")
@Html.Partial("Script")



@{
    int count = 0;
    int COLUMN_SIZE = 2;
}


@if (!ViewBag.logged)
{
    <div style="color: red">
        @Html.Raw("Please log in!")
    </div>
}
else
{
   //logged in
    if (ViewBag.wish.WishedAlbums.Count == 0 && ViewBag.wish.WishedSongs.Count == 0)
    {
        <div style="color: red">
        @Html.Raw("Empty wish list")
    </div>
    }
    else
    {
        <b>Albums wished:</b><br /><br />

       <div align="center" style="overflow:auto">
    <table>
      <col width="350px">
      <col width="200px">

        <tr>
        @for (int i = 0; i < ViewBag.wish.WishedAlbums.Count; i++)
        {
            <td>
                <img src="../Content/Image/emeil.jpg" style="height: 200px" onclick="ViewAlbum(@ViewBag.wish.WishedAlbums[i].ID)">
                <br /><b>@ViewBag.wish.WishedAlbums[i].Title</b>
                <br />$@ViewBag.wish.WishedAlbums[i].Price
                <br /><input type="button" value ="Un-wish" onclick="UnWish(@ViewBag.typeAlbum, @ViewBag.wish.WishedAlbums[i].ID)" />
                <br />&nbsp
            </td>
                if (++count % COLUMN_SIZE == 0)
                {                     
                @:</tr> 
                @:<tr> 
                }

        }
        </tr>

    </table>
</div>



<br />
<br />
<hr width="900" />
<b>Songs wished:</b>
<div align="center" style="overflow:auto">
    <table style="height:200px">
      <col width="500px">
      <col width="500px">
      <col width="100px">
      <col width="100px">
      <col width="100px">
      <col width="100px">
    <tr>
      <td><b>Title</b></td> 
      <td><b>Artist</b></td>
      <td><b>Duration(s)</b></td>
      <td><b>Price</b></td>
    </tr>


     @for (int i = 0; i < ViewBag.wish.WishedSongs.Count; i++)
     {
         string artist = "";     
         <tr>
            <td>@ViewBag.wish.WishedSongs[i].Title</td>
            <td>
                @for (int k = 0; k < ViewBag.wish.WishedSongs[i].Artists.Count; k++)
                {
                    if (k == 0)
                    {
                        artist = ViewBag.wish.WishedSongs[i].Artists[k].Name;
                    }
                    else
                    {
                        artist = artist + " & " + ViewBag.wish.WishedSongs[i].Artists[k].Name;
                    }
                }
                @Html.Raw(artist)
            </td> 
            <td>@ViewBag.wish.WishedSongs[i].Duration</td>
            <td>$@ViewBag.wish.WishedSongs[i].Price</td>
            @if (ViewBag.type != "Y")
            {
                 <td> 
                    <label class="cartCheckBox">
                        <input type="checkbox" id="@ViewBag.wish.WishedSongs[i].ID" onclick="TransactionCart(@ViewBag.typeSong, @ViewBag.wish.WishedSongs[i].ID)"/>
                        <span></span>
                    </label>
                </td>
                <td> 
                    <label class="favCheckBox">
                        <input type="checkbox" id ="@("f" + ViewBag.wish.WishedSongs[i].ID)" onclick="FavouriteCart(@ViewBag.typeSong, @ViewBag.wish.WishedSongs[i].ID)"/>
                        <span></span>
                    </label>
                </td>
            }
            <td><input type="button" onclick="ViewSong(@ViewBag.wish.WishedSongs[i].ID)" value="Details" /></td>
             <td><input type="button" value ="Un-wish" onclick="UnWish(@ViewBag.typeSong, @ViewBag.wish.WishedSongs[i].ID)" /></td>
            <td>&nbsp&nbsp</td>
        </tr>
     }
    
    </table>
</div>
    }
}

